package com.s3.khospitalds.controller;

import com.s3.khospitalds.common.R;
import com.s3.khospitalds.entity.Complaininfo;
import com.s3.khospitalds.service.ComplaininfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: xw
 * @CreateTime: 2025/2/20
 * @Description: 投诉类
 * @Version: 1.0
 */
@RestController
@CrossOrigin(origins = "*")
public class ComplaininfoController {
    @Autowired
    private ComplaininfoService complaininfoService;
    //查询护士所有投诉信息
    @GetMapping("/getAllComplain")
    public R getAllComplain() {//投诉信息
        return new R().addData("Complain",complaininfoService.selectComplaininfo());
    }
    //新增护士投诉信息
    @PostMapping("/insertComplain")
    public R insertComplain(@RequestBody Complaininfo complaininfo) {//新增投诉信息
        return new R().addData("Complain",complaininfoService.insertComplaininfo(complaininfo));
    }
    //修改护士投诉信息
    @PostMapping("/updateComplain")
    public R updateComplain(@RequestBody Complaininfo complaininfo) {//回复信息
        return new R().addData("Complain",complaininfoService.updateComplaininfo(complaininfo.getReply(), (int) complaininfo.getId()));
    }
    //删除护士投诉信息
    @PostMapping("/deleteComplain")
    public R deleteComplain(@RequestBody int id) {//根据id删除投诉信息
        return new R().addData("Complain",complaininfoService.deleteComplaininfo(id));
    }
}
